From 69370cc992643992941d7d65d591f26cc2bf0cc3 Mon Sep 17 00:00:00 2001 From: Alastair Tse Date: Thu, 7 Dec 2006 16:08:44 +0000 Subject: [PATCH] [XEND] Sync Xen API with newer VDB and VIF specification. Fix breakage with storing VIF and VBD refs, remove extraneous debugging. Also fixing some type errors in default values for Xen API if things are missing in XendConfig. Signed-off-by: Alastair Tse --- tools/python/xen/xend/XendAPI.py | 11 +++--- tools/python/xen/xend/XendConfig.py | 5 ++- tools/python/xen/xend/XendDomainInfo.py | 46 +++++++------------------ 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index 0b4e35b8ce..f59153e68b 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -1036,8 +1036,8 @@ class XendAPI: # regular xm created VBDs VBD_attr_ro = ['image', - 'IO_bandwidth_incoming_kbs', - 'IO_bandwidth_outgoing_kbs'] + 'io_read_kbs', + 'io_write_kbs'] VBD_attr_rw = ['VM', 'VDI', 'device', @@ -1113,10 +1113,8 @@ class XendAPI: # Xen API: Class VIF # ---------------------------------------------------------------- - VIF_attr_ro = ['network_read_kbs', - 'network_write_kbs', - 'IO_bandwidth_incoming_kbs', - 'IO_bandwidth_outgoing_kbs'] + VIF_attr_ro = ['io_read_kbs', + 'io_write_kbs'] VIF_attr_rw = ['name', 'type', 'device', @@ -1138,6 +1136,7 @@ class XendAPI: return xen_api_error(XEND_ERROR_VIF_INVALID) valid_vif_keys = self.VIF_attr_ro + self.VIF_attr_rw + \ self.Base_attr_ro + self.Base_attr_rw + for k in cfg.keys(): if k not in valid_vif_keys: del cfg[k] diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py index 526e8836a5..74ff06284d 100644 --- a/tools/python/xen/xend/XendConfig.py +++ b/tools/python/xen/xend/XendConfig.py @@ -925,7 +925,6 @@ class XendConfig(dict): if dev_type == 'vif' and 'ip' in dev_info: dev_info['ip'] = _get_config_ipaddr(config) - log.debug('XendConfig: IP Address: %s' % dev_info['ip']) if dev_type == 'vbd': if dev_info.get('dev', '').startswith('ioemu:'): @@ -944,12 +943,12 @@ class XendConfig(dict): param = '%s_refs' % dev_type if param not in target: target[param] = [] - if dev_uuid in target[param]: + if dev_uuid not in target[param]: target[param].append(dev_uuid) elif dev_type in ('tap',): if 'vbd_refs' not in target: target['vbd_refs'] = [] - if dev_uuid in target['vbd_refs']: + if dev_uuid not in target['vbd_refs']: target['vbd_refs'].append(dev_uuid) return dev_uuid diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index a86518ab40..3716be8462 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -1780,13 +1780,13 @@ class XendDomainInfo: return dom_uuid def get_memory_static_max(self): - return self.info.get('memory_static_max') + return self.info.get('memory_static_max', 0) def get_memory_static_min(self): - return self.info.get('memory_static_min') + return self.info.get('memory_static_min', 0) def get_memory_dynamic_max(self): - return self.info.get('memory_dynamic_min') + return self.info.get('memory_dynamic_min', 0) def get_memory_dynamic_min(self): - return self.info.get('memory_dynamic_max') + return self.info.get('memory_dynamic_max', 0) def get_vcpus_policy(self): @@ -1820,7 +1820,7 @@ class XendDomainInfo: def get_builder(self): return self.info.get('builder', 0) def get_boot_method(self): - return self.info.get('boot_method', '') + return self.info.get('boot_method', XEN_API_BOOT_TYPE[2]) def get_kernel_image(self): return self.info.get('kernel_kernel', '') def get_kernel_initrd(self): @@ -1830,7 +1830,7 @@ class XendDomainInfo: def get_grub_cmdline(self): return '' # TODO def get_pci_bus(self): - return 0 # TODO + return '' # TODO def get_tools_version(self): return {} # TODO def get_other_config(self): @@ -1925,18 +1925,16 @@ class XendDomainInfo: config['network'] = '' # Invalid for Xend config['MTU'] = 1500 # TODO - config['network_read_kbs'] = 0.0 - config['network_write_kbs'] = 0.0 - config['IO_bandwidth_incoming_kbs'] = 0.0 - config['IO_bandwidth_outgoing_kbs'] = 0.0 + config['io_read_kbs'] = 0.0 + config['io_write_kbs'] = 0.0 if dev_class == 'vbd': - config['VDI'] = '' # TODO + config['VDI'] = config.get('VDI', '') config['device'] = config.get('dev', '') config['driver'] = 'paravirtualised' # TODO config['image'] = config.get('uname', '') - config['IO_bandwidth_incoming_kbs'] = 0.0 - config['IO_bandwidth_outgoing_kbs'] = 0.0 + config['io_read_kbs'] = 0.0 + config['io_write_kbs'] = 0.0 if config['mode'] == 'r': config['mode'] = 'RO' else: @@ -2050,27 +2048,7 @@ class XendDomainInfo: return dev_uuid def has_device(self, dev_class, dev_uuid): - return (dev_uuid in self.info['%s_refs' % dev_class]) - - """ - def stateChar(name): - if name in self.info: - if self.info[name]: - return name[0] - else: - return '-' - else: - return '?' - - state = reduce(lambda x, y: x + y, map(stateChar, DOM_STATES_OLD)) - - sxpr.append(['state', state]) - - if self.store_mfn: - sxpr.append(['store_mfn', self.store_mfn]) - if self.console_mfn: - sxpr.append(['console_mfn', self.console_mfn]) - """ + return (dev_uuid in self.info['%s_refs' % dev_class.lower()]) def __str__(self): return '' % \ -- 2.30.2